//
//  CEPointListController.m
//  digitalCurrency
//
//  Created by 默认账户 on 2019/4/3.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CEPointListController.h"
#import "CEPiontHeaderView.h"
#import "CEPointInsCell.h"
#import "CEPointInstructionModel.h"

@interface CEPointListController()
@property (nonatomic, strong) CEPiontHeaderView *headerview;
@property (nonatomic, strong) NSMutableArray *goldList;

@end

@implementation CEPointListController
- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.viewTitle.text = [NSString stringWithFormat:@"%@ %@",_level,LocalizationKey(@"generation")];
    self.goldList = [NSMutableArray array];
    
    [self.view addSubview:self.tableView];
    [self.tableView registerClass:[CEPointInsCell class] forCellReuseIdentifier:@"setcell"];

    self.tableView.tableHeaderView = self.headerview;
    
    [self headRefreshWithScrollerView:self.tableView];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    
    self.tableView.frame = self.view.bounds;
}


-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return self.list.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{    
    CEPointInsCell *cell = [CEPointInsCell createTableView:tableView];
   
    NSDictionary *teamList = self.list[indexPath.row];
    cell.firstL.text   = [self handlePhone:teamList[@"phone"]];
    cell.secondL.text  = [NSString stringWithFormat:@"%@",teamList[@"userStar"]];
    cell.thirdL.text   = [NSString stringWithFormat:@"%@",[ToolUtil judgeStringForDecimalPlaces:[NSString stringWithFormat:@"%@",teamList[@"referTeamAsset"]] point:4]];
    
    return cell;
}

- (NSString *)handlePhone:(NSString *)number {
    if (number.length <= 0) {
        return number;
    }
    
    if (number.length < 7) {
        return number;
    }
    
    NSString *phone = [number stringByReplacingCharactersInRange:NSMakeRange(3, 4) withString:@"****"];
    return phone;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(nonnull NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
}

- (CEPiontHeaderView *)headerview {
    if (!_headerview) {
        _headerview = [[CEPiontHeaderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 64)];
        _headerview.backgroundColor = [UIColor colorWithHEX:mainBlackColor];
        _headerview.titles = @[LocalizationKey(@"User name"),LocalizationKey(@"Class"),LocalizationKey(@"Performance (CT)")];
    }
    
    return _headerview;
}

@end
